function Swiper(el){

    this.el=document.querySelector(el)
    this.t=null
    this.num=1
    this.init()
}

Swiper.prototype.init=function(){

    this.autoplay()
    this.over()

}

Swiper.prototype.page=function(num){
    this.el.querySelector('ul li.active').className=''
    this.el.querySelectorAll('ul li')[num-1].className='active'
}

//定时器
Swiper.prototype.autoplay=function(){


    this.t=setInterval(()=>
    {
        this.num++
        if(this.num>6) this.num=1
        this.el.querySelector('img').src=`./imgs/img${this.num}.jpg`

        //同步分页器
 

        this.page(this.num)

    },1000)

}



//鼠标移入
Swiper.prototype.over=function(){
    let ulliObjs=this.el.querySelectorAll('ul li')
    ulliObjs.forEach((item,i)=>{
        item.onmouseover=()=>
        {
        clearInterval(this.t)

        this.el.querySelector('img').src=`./imgs/img${i+1}.jpg`
        this.num=i+1
        this.page(this.num)

        }

        item.onmouseout=()=>{
            this.autoplay()

        }

    })

}



//鼠标移出
// Swiper.prototype.out=function(){
//     this.autoplay()
// }